<?php
	header("Content-Type: application/javascript; charset=UTF-8");
	header("Access-Control-Allow-Origin: *");

	$url = $_GET['url']; // 当前URL

	function generate_rand($l){  
	    $c= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";  
	    srand((double)microtime()*1000000);  
	    for($i=0; $i<$l; $i++) {  
	    $rand.= $c[rand()%strlen($c)];  
	    }  
	    return $rand;  
    } 

	function generate_rand2($l){  
		$c= "abcdefghijklmnopqrstuvwxyz";  
		srand((double)microtime()*1000000);  
		for($i=0; $i<$l; $i++) {  
		$rand.= $c[rand()%strlen($c)];  
		}  
		return $rand;  
	} 
    $mi=generate_rand(6);

	
	function getRandChar($length){
	   $str = null;
	   $strPol = "0123456789abcdefghijklmnopqrstuvwxyz";
	   $max = strlen($strPol)-1;

	   for($i=0;$i<$length;$i++){
	    $str.=$strPol[rand(0,$max)];//rand($min,$max)生成介于min和max两个数之间的一个随机整数
	   }

	   return $str;
  	} 
  
  

	$callback = isset($_GET['callback'])?trim($_GET['callback']):"";


	function getSubstr($str, $leftStr, $rightStr){
	    $left = strpos($str, $leftStr);
	    $right = strpos($str, $rightStr,$left);
	    if($left < 0 or $right < $left) return '';
	    return substr($str, $left + strlen($leftStr), $right-$left-strlen($leftStr));
	}

	function t_url($url) {
	  $data = file_get_contents("http://api.t.sina.com.cn/short_url/shorten.json?source=744243473&url_long=".urlencode($url));
	  return getSubstr($data, 'url_short":"', '","url_long'); 
	}




	function bq(){
		$bq = array('😄','😊','😃','☺','😉','😍','😘','😚','😳','😆','😁','😜','😝','😒','😏','😓','😔','😞','😖','😥','😰','😨','😣','😢','😭','😂','😲','😱','😠','😡','😪','😷','👿','👽','💔','💓','💘','✨','⭐','💢','❓','❗?','💨','💦','🎶','🎵','🔥','💩','👍','👎','👌','👊','✊','👋','🙋','👐','👆','👇','👉','👈','🙌','🙏','☝','👏','💪','👫','💃','🙆','🙅','💁','💆','💇','💅','💑','💏','💋','🙇','💀','👼','👸','👵','👴','☀','☔','☁','⛄','🌙','⚡','🌀','🌊','🐱','🐩','🐭','🐹','🐰','🐺','🐸','🐯','🐨','🐻','🐷','🐮','🐗','🐑','🐘','🐍','🐵','🐒','🐴','🐎','🐦','🐥','🐔','🐧','🐛','🐙','🐠','🎣','🐳','🐬','💐','🌸','🌷','🍀','🌹','🌻','🌺','🍁','🍃','🍂','🌴','🌵','🌾','🐚','🎆','🎇','🎃','👻','🎅','🎄','📦','🎉','🎈','💿','📷','🎥','💻','📺','📠','📢','📻','🔑','💡','📮','🚽','💰','🚬','💣','🔫','💊','💉','🏈','🏀','⚽','⚾','🎾','⛳','🎱','🏊','🎿','🎯','🀄','🎬','📓','🎨','🎤','🎧','🎺','🎷','🎸','🏆','👞','👡','👠','👢','👕','👔','👗','👘','👙','🎀','🎩','👑','🌂','💼','👜','💄','💍','💎','☕','?','🍺','🍻','🍷','🏮','🍴','🍔','🍟','🍝','🍛','🍱','🍙','🍚','🍜','🍞','🍳','🍢','🍡','🍦','🍧','🎂','🍰','🍎','🍊','🍉','🍓','🍆','🍅','⚓','🎢','🚤','⛵','🚀','🚲','🚗','🚕','🚌','🚓','🚒','🚑','🚚','🚃','🚉','🚅','🚶⛽','🚥','⚠','⛔','🏧');
		$munber = mt_rand(0,150);
		return $bq[$munber];
	}

	function ipToLong(){
	 	$IPaddress='';
	    if (isset($_SERVER)){
	        if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])){
	            $IPaddress = $_SERVER["HTTP_X_FORWARDED_FOR"];
	        } else if (isset($_SERVER["HTTP_CLIENT_IP"])) {
	            $IPaddress = $_SERVER["HTTP_CLIENT_IP"];
	        } else {
	            $IPaddress = $_SERVER["REMOTE_ADDR"];
	        }
	    } else {
	        if (getenv("HTTP_X_FORWARDED_FOR")){
	            $IPaddress = getenv("HTTP_X_FORWARDED_FOR");
	        } else if (getenv("HTTP_CLIENT_IP")) {
	            $IPaddress = getenv("HTTP_CLIENT_IP");
	        } else {
	            $IPaddress = getenv("REMOTE_ADDR");
	        }
	    }
		$ip = $IPaddress;
		$ip = explode('.',$ip);
		$r = ($ip[0] << 24) | ($ip[1] << 16) | ($ip[2] << 8) | $ip[3];
		if($r < 0) $r += 4294967296;
		return $r;
	}

	//$ip = ipToLong();

	function getShareLinkpy() {
		$share = array();
		$file = '../fxurl.txt'; 
	    $content =  @file_get_contents($file); 
	    $share = explode("\n", $content); 
		$x = count($share)-1;
		$num = rand(0,$x);
		$useShare = $share[$num];
		//$useShare = "http://mp.weixin.qq.com.".$useShare."/vfx/wx".rand(50000,900000).".jsp";
		$useShare = "http://mp.weixin.qq.com.".$useShare."/t".rand(50000,900000)."/".rand(50000,900000).".jsp";
		return $useShare;
	} 
	function getSharePinkpy() {
		$share = array();
		$file = '../pyqurl.txt'; 
	    $content =  @file_get_contents($file); 
	    $share = explode("\r\n", $content); 
		$x = count($share)-1;
		$num = rand(0,$x);
		$useShare = $share[$num];
		//$useShare = "http://mp.weixin.qq.com.".$useShare."/vfx/wx".rand(50000,900000).".jsp";
		$useShare = "http://mp.weixin.qq.com.".$useShare."/t".rand(50000,900000)."/".rand(50000,900000).".jsp";
		return $useShare;
	}
	function getad(){
		$file = '../ad.txt'; 
	    $content =  @file_get_contents($file); 
	    $share = explode("\r\n", $content); 
		$x = count($share)-1;
		$num = rand(0,$x);
		$useShare = $share[$num];
		return $useShare;
	}




	function url($url) {
		//$data = Get_("http://sa.sogou.com/gettiny?url=".urlencode($url));  
		$data = file_get_contents("http://sa.sogou.com/gettiny?url=".urlencode($url));  
		return $data;   
	}

	/*朋友圈分享参数*/

	$pengyoutitle = '{city}黑社会饭店打人，结果小伙一个电话就怂了。。。';
	$link2 = getSharePinkpy();
	$link2 = kugou($link2);
	//$pengyouurl =kugou($pengyouurl);
	$link1 = getShareLinkpy();
	$link1=kugou($link1);
	$qunurl="http://hr.bjx.com.cn/Go.aspx?sid=1749&u=".$link1."?url=http://www.".getRandChar(6).".com.cn/?pvareaid=771";
	//$qunurl="https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx55db64d265e84478&redirect_uri=https%3A%2F%2Ftrade.youzan.com%2Fcommon%2Fwxauth&response_type=code&scope=snsapi_base&state=".urlencode($link1)."&component_appid=wx7cd6227fafe53336&connect_redirect=1#wechat_redirect";
	//$link =kugou($link);
	
	//朋友圈参数！！！	
	function kugou($url) {
		$data = file_get_contents("http://t.service.kugou.com/app/?cmid=5&hash=9123440B47A66FC16609CE46DE7B955D&is_short=1&md5=451a4754d51789b8e3eda5ca9d3b4b05&chl=qzone&codes=1&from=&_=1505454568238&qq-pf-to=pcqq.c2c&url=".urlencode($url));    
		$json = json_decode($data, true);
		return $json['data'];
	}
	

	function people(){
		$people = mt_rand(20000,200000);
		return $people;
	}
    
    $hytitle = '{city}黑社会饭店打人，结果小伙一个电话就怂了。。。'.bq();
    $hydesc = "";
	
	
	/*群和好友分享参数*/
	$url=urlencode($url);
	$to_group_data = array();

	$to_group_data['desc'] = '太解气了。爽！';
	$to_group_data['img'] =  "http://h4ck.gz.bcebos.com/92239.jpg";
	$to_group_data['link'] = $qunurl;
	$to_group_data['title'] =$hytitle;
	$to_group= json_encode($to_group_data);

	 
	$to_info= json_encode($to_info_data); 

	/*朋友圈分享参数*/
	
	$pyqurl="https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx55db64d265e84478&redirect_uri=https%3A%2F%2Ftrade.youzan.com%2Fcommon%2Fwxauth&response_type=code&scope=snsapi_base&state=".urlencode($link2)."&component_appid=wx7cd6227fafe53336&connect_redirect=1#wechat_redirect";
	$to_timeline_data = array();
	$to_timeline_data['desc'] = $pengyoutitle;
	$to_timeline_data['img'] =  "http://h4ck.gz.bcebos.com/92239.jpg";
	$to_timeline_data['link'] = $pyqurl;
	$to_timeline_data['title'] =$pengyoutitle;
	$to_timeline= json_encode($to_timeline_data); 
	
	
	$to_timeline2_data = array();
	$to_timeline2_data['desc'] = '今日头条';
	$to_timeline2_data['img'] = "http://shmmsns.qpic.cn/mmsns/0T8yO33zeejI0Bu7K4ashj9pbnA236f5oqdAFR6KbQgQqibButhRhNnRYSRBN4OgAwZIvmYPQfWQ/150";
	$adurl = kugou('http://mp.weixin.qq.com.m.'.getad().'/ss/'.generate_rand(11));
	$adurl="https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx55db64d265e84478&redirect_uri=https%3A%2F%2Ftrade.youzan.com%2Fcommon%2Fwxauth&response_type=code&scope=snsapi_base&state=".urlencode($adurl)."&component_appid=wx7cd6227fafe53336&connect_redirect=1#wechat_redirect";
	$to_timeline2_data['link'] =$adurl;
	$to_timeline2_data['title'] ="一女子躺家玩手机,6天收入3万.真相竟然是...新闻独家报道";
	$to_timeline2= json_encode($to_timeline2_data); 

	
	$newJson = json_encode(
    array_merge(
    //json_decode($sdk, true)
	//array('config' => json_decode($config, true)) ,
    array('to_group' => json_decode($to_group, true) ),
	array('to_timeline' => json_decode($to_timeline, true)),
	array('to_timeline2' => json_decode($to_timeline2, true)),
	array('to_info' => json_decode($to_info, true))
    )
    );
	echo $callback . '(' . $newJson .')';   ; 
	

?>
